package weeek11.topic06;

import org.redisson.Redisson;
import org.redisson.api.RDeque;
import org.redisson.api.RList;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import redis.clients.jedis.Jedis;

import java.util.Set;

/**
 * @author lfy
 */
public class RedissonTest {
    public static void main(String[] args) {
        Config config = new Config();
        config.useSingleServer().setAddress("redis://127.0.0.1:6379");
        RedissonClient redisson = Redisson.create(config);


        //list类型的操作
        RList<Object> list = redisson.getList("list_key");
        list.add("list_v1");
        list.add("list_v2");

        while (list.size() > 0) {
            Object val = list.get(0);
            System.out.println("list read:" + val);
            list.remove(0);
        }
        //双端队列
        RDeque<Object> dequeue = redisson.getDeque("dequeue");
        dequeue.add("d1");
        dequeue.add("d2");
        while (dequeue.size() > 0) {
            Object val = dequeue.pop();
            System.out.println("dequeue read:" + val);
        }
    }


}
